﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using Analysis.Business;

namespace Analysis
{
    public partial class frmAyarlar : XtraForm
    {
        private bool kaydetKapat = false;

        public frmAyarlar()
        {
            InitializeComponent();
        }

        public frmAyarlar(bool close)
        {
            InitializeComponent();
            kaydetKapat = close;
        }
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            for (int i = 1; i < vGridControl1.Rows.Count; i++)
            {
                if (vGridControl1.Rows[i].Properties.Value != null)
                    Config.GetConfig.Add((Parametre)Enum.Parse(typeof(Parametre), vGridControl1.Rows[i].Properties.FieldName), vGridControl1.Rows[i].Properties.Value.ToString());
            }
            Config.GetConfig.Save();
            if (kaydetKapat)
                Application.Exit();
        }

        private void frmAyarlar_Load(object sender, EventArgs e)
        {
            for (int i = 1; i < vGridControl1.Rows.Count; i++)
            {
                if (!string.IsNullOrEmpty(vGridControl1.Rows[i].Properties.FieldName)) vGridControl1.Rows[i].Properties.Value = Config.GetConfig.GetValue((Parametre)Enum.Parse(typeof(Parametre), vGridControl1.Rows[i].Properties.FieldName));
            }
        }
    }
}
